using System;
using System.Data;
using System.Collections.Generic;
using System.Collections;
using log4net;
using FSS.DAL.DBManagers;
using FSS.BLL.Entities;
namespace FSS.BLL.Services
{
	#region IVoucherService

	/// <summary>
	/// VoucherService object for Ibatis mapped table 'Voucher'.
	/// </summary>
	public class IVoucherService : BaseSqlMapDao
	{
		private static readonly ILog log = LogManager.GetLogger(typeof(IVoucherService).Name);
	  	
		public IList<VoucherEntity> LoadAll()
        {
            try
            {
                return ExecuteQueryForList< VoucherEntity>("VoucherLoadAll", null);
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message);
                return null;
            }
        }
       public VoucherEntity LoadByPrimaryKey(VoucherEntity objE)
        {
            try
            {
                return ExecuteQueryForObject< VoucherEntity>("VoucherLoadByPrimaryKey", objE);
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message);
                return null;
            }
        }
        
        /// <summary>
        /// add new Voucher to DB 
        /// </summary>
        /// <param name="objE"></param>
        /// <returns></returns>
        public int Insert(VoucherEntity objE)
        {
            try
            {
                ExecuteInsert("VoucherInsert", objE);
                return 1;
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message);
                return 0;
            }
        }
        /// <summary>
        /// update Voucher to DB 
        /// </summary>
        /// <param name="objE"></param>
        /// <returns></returns>
        public int Update(VoucherEntity objE)
        {
            try
            {
                ExecuteUpdate("VoucherUpdate", objE);
                return 1;
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message);
                return 0;
            }
        }
        /// <summary>
        /// delete Voucher to DB 
        /// </summary>
        /// <param name="objE"></param>
        /// <returns></returns>
        public bool Delete(Int64 VoucherId)
        {
            try
            {
                VoucherEntity objE = new VoucherEntity
                {
                    VoucherId = VoucherId
                };
             int Resul=(int) ExecuteDelete("VoucherDelete", objE);
             return (Resul>0);
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message);
                throw ex;
            }
        }
	}
	#endregion  
}
